<?php
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../src/utils/JWTUtils.php';

use src\utils\JWTUtils;

$_ENV['JWT_EXPIRATION'] = 3600;
$_ENV['JWT_SECRET'] = '2310d191d7d8b5eaea9e69b056e114f36998030c69fe2bd862c0677f183f710d';
$user = [
    'id' => 1,
    'username' => 'admin',
    'email' => 'admin@gmail.com',
    'role' => 'admin'
];
try {
    $encode = JWTUtils::generateToken($user);
    $encode = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJibG9nX3N5c3RlbSIsImlhdCI6MTc1ODg1OTI1NywiZXhwIjoxNzU4ODYyODU3LCJ1c2VyIjp7ImlkIjo3LCJ1c2VybmFtZSI6InRvbSIsInJvbGUiOiJ1c2VyIn19.0EfTVuzGWrAA4gSvX6dTmMLg3BR9Qzg-0TlXS3cXJyQ';
    $user_decode = JWTUtils::decodeToken($encode);
} catch (Exception $e) {
    echo $e->getMessage();
    exit;
}

echo json_encode($encode) . '\n';
echo '                     ';
echo json_encode($user_decode) . '\n';
echo '                     ';


// $decoded = null;
// if (empty($decoded)) {
//     echo 1;
// } else {
//     echo 0;
// }

?>